home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / comm / dep309.zip / DEPARC.EXE / SCRIPTS.EXE / MICKEY.DSL < prev    next >
Text File  |  1993-07-14  |  7KB  |  183 lines

  1.  
  2. SCRIPT Mickey;
  3.  
  4. (* Deputy DSL Demonstration Script Version 1.3 *)
  5. (* Copyright 1992 Michael Spalter & SEG *)
  6. (* This script makes use of the following DSL commands:
  7.  
  8.    Functions Returning Booleans        Procedures
  9.    ----------------------------        ----------
  10.    Fexists(filename)                   FDelete(filename)
  11.    DCD                                 FRename(oldname,newname)
  12.    FEOF(filehandle)                    Write(string)
  13.    KeyPressed                          WrLn
  14.                                        ClrScr
  15.                                        Hangup
  16.    Functions Returning Integers        WriteStatus(String)
  17.    ----------------------------        Alarm
  18.    FileSize(filename)                  ForeGnd(colour)
  19.    ScriptTime                          BackGnd(colour)
  20.    Pos(searchstring,bigstring)         OpenLog(filename)
  21.    Length(stringvar)                   CloseLog
  22.    ABS()    WhereY                     GoToXY(x,y)
  23.    Menu(....)                          StatusLine(Boolean)
  24.                                        INC(integervar[,number])
  25.    Functions Returning Strings         StrToInt(string,intvar)
  26.    ---------------------------         Read(stringvar)
  27.    Time
  28.    Date
  29.    Caps(StringVar)   *)
  30.  
  31. (* First, define the variables used in the script *)
  32.  
  33. VAR YourName:String[18];
  34.     Happiness:Integer;
  35.     Value:Integer;
  36.     FileLine:String[78];
  37.     ValueString:String[15];
  38.     LineCount:Integer;
  39.     FileBytes:Integer;     (* This is an enclosed comment *)
  40.     People:String[20];     (* Comments can be placed anywhere *)
  41.     FileHandle:Integer;    (* and are ignored by Deputy's Compiler *)
  42.  
  43.    (* Note: Apostrophes and Inverted commas are identical in function
  44.       It's best to use one type. In this script we have tried to use
  45.       apostrophes only,but where we need to write an apostrophe
  46.       to the screen, we use the inverted commas instead. *)
  47.  
  48.    (* Now the actual main script body starts *)
  49.  
  50.    BEGIN
  51.    StatusLine(TRUE);
  52.    ClrScr;
  53.    WriteStatus('        Welcome to the Deputy Demonstration script !');
  54.    StatusLine(TRUE);
  55.    Alarm();
  56.    OpenLog('Test.LOG');
  57.    GoToXY(20,10);
  58.    Write(' Hold on a few seconds......');
  59.       WHILE ScriptTime()<3 DO END;
  60.    WrLn;
  61.    ClrScr;
  62.    WriteStatus('');
  63.    GoToXY(0,5);
  64.    Write("\t The date is ",Date,", and the time is ",Time);  WrLn;
  65.    Write('\t This is a sample script using the Deputy');  WrLn;
  66.    Write('\t script language. It is designed to show ');  WrLn;
  67.    Write('\t the use of as many commands as possible.');  WrLn;
  68.  
  69.    FileBytes:=FSize('DEPUTY.EXE');
  70.    Write('\t The Deputy program is ',Filebytes,' bytes long,'); WrLn;
  71.    Write('\t and this script has been running ',ScriptTime(),' Secs.');
  72.    WrLn; WrLn;
  73.    Write('\t Who is with you (their names please) ? ');
  74.    Read(People); WrLn;
  75.       IF POS('JIM',Caps(People))<>-1 THEN
  76.       Write('\t I see that Jim is with you !'); WrLn;
  77.       ELSE
  78.       Write('\t I see that Jim is NOT with you with you !'); WrLn;
  79.       END;
  80.    Write('\t By the Way, that string was ',Length(People),' bytes');
  81.    WrLn; WrLn;
  82.    Write('\t Please enter a negative number: ');
  83.    Read(ValueString); WrLn;
  84.    StrToInt(ValueString,Value);  (* Convert it to an Integer first *)
  85.    Write('\t Okay. Without the sign, it equals ',ABS(Value)); WrLn;
  86.    Write('\t The Cursor is now at ',WhereX,',',WhereY()); WrLn;
  87.    WrLn;
  88.    Write("\t Please type in your first name: ");
  89.    Read(YourName); WrLn;
  90.    Write("\t I'm now going write your name to a file....");
  91.    Filehandle := FCreate('TestFile.TXT');
  92.    FWrite(FileHandle,YourName);
  93.    FClose(FileHandle);
  94.    Write('Done ! '); WrLn; WrLn;
  95.       IF NOT Fexists('TestFile.TXT') THEN
  96.       Write("\t Arrgghh ! File didn't Write properly !"); WrLn;
  97.       ELSE
  98.       Write("\t That seemed to work. Now I'll read it back.....");
  99.       YourName:= '';     (* Clear the String *)
  100.       FileHandle := FOpen('TestFile.TXT');
  101.       FRead(FileHandle,YourName);
  102.       FClose(FileHandle);
  103.       Write('Done !'); WrLn;
  104.       Write("\t According to the file, your name is ",YourName,".");
  105.       WrLn;
  106.       Write("\t I'll just delete that file now."); WrLn;
  107.       FDelete('TestFile.TXT');
  108.       END;
  109.    WrLn;
  110.    Write('\t Press any key to go on......');
  111.    WHILE NOT Keypressed() DO END;
  112.    WrLn;
  113.    ClrScr();
  114.    REPEAT Value:=RdKey() UNTIL NOT Keypressed();   (* Clear Kbd Buffer *)
  115.         Happiness := 1 + Menu(24,3,30,"How happy are you ?",
  116.                          "1 - Extremely happy ",
  117.                          "2 - Very Happy ",
  118.                          "3 - Quite Happy   ",
  119.                          "4 - Content",
  120.                          "5 - Nonchalent",
  121.                          "6 - A little sad",
  122.                          "7 - Upset",
  123.                          "8 - Completely distraught",28);
  124.       GoToXY(0,2);
  125.       CASE Happiness OF
  126.       1: Write("\t So, you're extremely happy - Good !");|
  127.       2: Write("\t You're very happy apparently");|
  128.       3: Write("\t You are quite happy - that's nice");|
  129.       4: Write("\t You are content - barely happy :-(");|
  130.       ELSE
  131.       Write("\t You are not happy at all - what a shame!");
  132.       END;
  133.      WrLn; WrLn;
  134.         IF NOT DCD THEN
  135.         Write('\t You are currently not online.'); WrLn;
  136.         ELSE
  137.         Write("\t You are currenly online, I'll just hangup"); WrLn;
  138.         Hangup;
  139.         END;
  140.      CloseLog;
  141.      FRename('Test.LOG','NewTest.LOG');
  142.      WrLn;
  143.      Write("\t Press a key to see a directory of your disc....");
  144.      WHILE NOT Keypressed() DO END;
  145.      REPEAT Value:=RdKey() UNTIL NOT KeyPressed();  (* Clear Kbd Buffer *)
  146.      DOSCMD('CLS',FALSE);
  147.      DOSCMD('DIR /w',TRUE);
  148.      ClrScr;
  149.      GoToXY(0,2);
  150.         If Fexists('NewTest.LOG') THEN
  151.         Write("\t Press any key for a review.......");
  152.         WHILE NOT Keypressed() DO END;
  153.         Happiness := RdKey();
  154.         WrLn; WrLn;
  155.         FileHandle:=FOpen('NewTest.LOG');
  156.         LineCount:= 0;
  157.         Repeat
  158.         FRead(FileHandle,FileLine);
  159.         ForeGnd(White);
  160.         Write('Review [ ');
  161.         ForeGnd(Yellow);
  162.         Write(FileLine);
  163.         Foregnd(White);
  164.         GoToXY(79,WhereY()); Write(']'); WrLn;
  165.         INC(LineCount);
  166.            If LineCount MOD 10 = 0 THEN
  167.            WrLn;
  168.            Write(' [ Press any key to continue ]');
  169.            WHILE NOT Keypressed() DO END;
  170.            While Keypressed() DO RdKey() END;
  171.            WrLn; WrLn;
  172.            END;
  173.         UNTIL FEOF(FileHandle);
  174.         WrLn;
  175.         FClose(FileHandle);
  176.         FDelete('NewTest.LOG');
  177.         Write(' [ End of Review (Length: ',LineCount,' Lines) ]');
  178.         END;
  179.         WrLn; WrLn;
  180.         Write('That is the end of the script !'); WrLn; WrLn;
  181.    END Mickey;
  182.  
  183.